package com.csd.activity;

import com.csd.view.BadgeView;

import android.app.ActionBar;
import android.app.Activity;
import android.app.ActionBar.LayoutParams;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class ResertPasswordActivity extends Activity implements OnClickListener{

	private Button bt_update;
	private ActionBar actionBar;
	private CsdApplication csdApp;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_resertpassword);
		initView();
		initActionBarView();
	}
	private void initView() {
		// TODO Auto-generated method stub
		bt_update = (Button) findViewById(R.id.update);
		bt_update.setOnClickListener(this);
		if(csdApp == null){
			csdApp = CsdApplication.getInstance();
		}
		actionBar = getActionBar();
		
	}

	private void initActionBarView() {
		// TODO Auto-generated method stub
		actionBar = getActionBar();
		actionBar.setDisplayHomeAsUpEnabled(false);
		actionBar.setDisplayShowHomeEnabled(false);
		actionBar.setDisplayShowTitleEnabled(false);
		actionBar.setDisplayShowCustomEnabled(true);
		LayoutInflater inflater = (LayoutInflater) this
				.getSystemService(this.LAYOUT_INFLATER_SERVICE);
		View v = inflater.inflate(R.layout.actionbar_main, null);
		TextView text = (TextView) v.findViewById(R.id.title);
		text.setText("修改密码");
		ImageView msg = (ImageView) v.findViewById(R.id.msg);
		msg.setImageDrawable(getResources().getDrawable(R.drawable.msg));
		ImageView img = (ImageView) v.findViewById(R.id.logo);
		img.setImageDrawable(getResources().getDrawable(R.drawable.u86));
		img.setOnClickListener(this);
		BadgeView badge = new BadgeView(this, msg);
		badge.setText("3");
		badge.show();
		ActionBar.LayoutParams layout = new ActionBar.LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
		actionBar.setCustomView(v, layout);
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.update:
			Intent intent = new Intent(this, MainActivity.class);
			intent.putExtra("num", 2);
			intent.putExtra("flag", 0);
			startActivity(intent);
			finish();
			break;
		case R.id.logo:
			Intent intent1 = new Intent(this, MainActivity.class);
			intent1.putExtra("num", 2);
			intent1.putExtra("flag", 0);
			startActivity(intent1);
			finish();
			break;
		default:
			break;
		}
		
	}
}
